﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DasEncryptor
{
    public partial class Form1 : Form
    {
 
        Boolean firstEnter = true;
        Boolean firstEnter2 = true;
        public Form1()
        {
            InitializeComponent();            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.UseSystemPasswordChar == false)
            {
                label1.Visible = false;
                label2.Visible = false;
                label3.Visible = true;
            }
            else
            {
                Encrypt(false);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.UseSystemPasswordChar == false)
            {
                label1.Visible = false;
                label2.Visible = false;
                label3.Visible = true;
            }
            else
            {
                Decrypt(false);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void copyTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(richTextBox1.Text);
        }

        private void pasteTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = Clipboard.GetText();
        }


       private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
               /* Decrypt(true);
                if (label1.Visible == false && label2.Visible == false && label3.Visible == false)
                {*/
                    e.Handled = true;
                //}
            }
        } 
        private void textBox1_Entered(object sender, EventArgs e)
        {
            if (firstEnter == true)
            {
                if (textBox1.Text.Equals("Password..."))
                {
                    textBox1.Text = "";
                    textBox1.UseSystemPasswordChar = true;
                    textBox1.ForeColor = Color.Black;
                    firstEnter = false;
                }
            }
            else
            {
                textBox1.SelectAll();
            }
        }
        private void textBox1_Left(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                textBox1.Text = "Password...";
                textBox1.UseSystemPasswordChar = false;
                textBox1.ForeColor = Color.LightGray;
                firstEnter = true;
            }
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String name = "Das Encryptor";
            String author = "Joshua Gause && Daniel Zinni";
            String copyright = "Copyright GTJ Works 2010";
            String company = "GTJ Works is an independent contractor";
            String description = "Das Encryptor is a simple but extremely useful message encrypting program. It is constantly being updated with new features and better encryption algorithms. And as always, Das Encryptor is free, open-source, and released under GNU General Public License v3.";
            AboutBox1 aboutBox = new AboutBox1(name, author, copyright, company, description);
            aboutBox.Show();
            
        }

        private void clearBoxToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            richTextBox1.Text = "";
        }

        private void clearPasswordToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Focused == true)
            {
                textBox1.Text = "";
            }
            else
            {
                textBox1.Text = "Password...";
                textBox1.UseSystemPasswordChar = false;
                textBox1.ForeColor = Color.LightGray;
                firstEnter = true;
            }
        }

        private void Encrypt(bool test)
        {
            if (textBox1.Text != "")
            {
                if (label1.Visible == true | label2.Visible == true)
                {
                    label1.Visible = false;
                    label2.Visible = false;
                    label3.Visible = false;
                }
                String encrypt = AESEncryption.Encrypt(richTextBox1.Text, textBox1.Text, salt(), "SHA1", 2, "r0#a1etooriuj4ek", 256);
                richTextBox1.Text = encrypt;
            }
            else
            {
                label1.Visible = false;
                label2.Visible = false;
                label3.Visible = true;
            }
        }

        private void Decrypt(bool test)
        {
            if (textBox1.Text != "")
            {
                String decrypt = AESEncryption.Decrypt(richTextBox1.Text, textBox1.Text, salt(), "SHA1", 2, "r0#a1etooriuj4ek", 256);
                if (decrypt.Equals("exception ce"))
                {
                    if (richTextBox1.Text.Length == 4)
                    {
                        label1.Visible = false;
                        label2.Visible = true;
                        label3.Visible = false;
                    }
                    else
                    {
                        label2.Visible = false;
                        label1.Visible = true;
                        label3.Visible = false;
                    }
                }
                else if (decrypt.Equals("exception fe"))
                {
                    if (test == true)
                    {
                        Encrypt(false);
                    }
                    else
                    {
                        label1.Visible = false;
                        label2.Visible = true;
                        label3.Visible = false;
                    }
                }
                else
                {
                    if (label1.Visible == true | label2.Visible == true)
                    {
                        label1.Visible = false;
                        label2.Visible = false;
                        label3.Visible = false;
                    }
                    richTextBox1.Text = decrypt;
                }
            }
            else
            {
                label1.Visible = false;
                label2.Visible = false;
                label3.Visible = true;
            }
        }

        private string salt()
        {
            String saltAES = "y+(Y2!n&)G^or0uca-";
            String hdcpAESalt = "6692d179032205b4116a96425a7fecc2ef51af1740959d3b6d07bce4fa9f2af29814d982592e77a204a8146a6970e3c4a1f43a81dc36eff7568b44f60c79f5bb606d7fe87dd61b91b9b73c68f9f31c6aeef81de69a9cc14469a037a480bc978970a6997f729d0a1a39b3b9accda43860f9d45a5bf64a1d180a1013ba502342b73df2d33112851f2c4d21b05e2901308bbd685c9fde452d3328f54cc518f97414a88fca1f7e2a0a14dc8bdbb12e2378672f11cedf36c5f45a2a00da1c1d5a3e82c124129a084a707eadd972cb45c81b64808d07ebd2779e3e719663e2beeee6e525078568d83de828027d5c0c4e65ec3f0fc32c7e631d6b501ae0f003f5a8fcecb28092854349337aa99e9c669367e08bf1d9c23474e09f703c901d46bada9a40981ffcfa376fa4b686ca8fb03963f2ce16b918631bade89cc52ca24552921af8efd2fe8ac96a02a6f99248b8894b23bd17535dbff93d5694bdc32a095df2cd247c6d30286ed2212f9d8ce80adc55bdc2a6962cbcabf9b5fcbe6fc2cfc78f5fdafa80e32223b9feabf1fa23f5b0bf0dab6bf4b5b698aed960315753d36f424701e5a944ed10f61245ebe788f57a17fc53a31400e22e88911d9e76575e18c7956ec1ef4eee022e38f5459f177591d908748f861098ef287d2c63bd809ee6a28a6f5d000c7ae5964a663c1b0f15f7167f56c6d6c05b2bbe8800544a49be026410d9f3f08602517f74878dc02827f7d72ef3ea24b7c8717c7afc0b55a50be2a582516d08202ded173a54289b71e35e45943f9e7cd2c8789c991b590a91f1cffd903dca7c36d29852ad58ddcc186156dd3acba0d9c5c76254c1be9ed106ecb6ae8ff373cfcc1afcbc80a430eba7ac19308cd6e20ae760c986c0d1e59db1075f8933d5d8284b929280d9a3faa7168386984f92bfd6be56cd7c4bfa5916593d2aa598a6d62534326a40ee0c1f1919936667acbaf0eefdd39536dbfdbf9e14390bd7c7e683d28054759e16cfd9eacac9029104bd51436d1dca1371d3ca2f808654cdb27d6923e47f97b570e256b741910c7dd466ed5fff2e26bec4a28e8cc45754ea7219d4eb75270aa4d3cc8de0ae1d1897b7f44fe5663e8cb34205a80e4a1a950d66b4eb6ed4c99e3d7e9d469c616581677af04a2e15ada4be60bc348ddfdfbbad73924898ad5986f3ca1f971d02ada31b462adab96f7b15da9855f01b9b7b946cef0f65663fbfeb328e8a3c6c5de29f0f0b1ef2bfe4a30b29047d3152250e7ae3a4acfe3efc3b8c2df18c997d15d6078b49da8b4611ff9fb1e061bc9be99531fd68c4ad6dc6fd8974f0c506dd90421c1cd2b26c53eec84c91ed175159ba3711173b25e318ddceea6a98a141257559552bb97fd341cea23f8404769a0a8ebce5c7a45fb5d49608307b43f7852a98e5856afe75b4dbead4815cacd1118af62c964a3142667a5b0d146c6f90933acd3d6b14a0052e2be41b1811fda0f55412300aa7f104051919ca0bff56ead3e2f3aad5250c4aeeea5101d2ec377fc499c070576cb1a90cdb7b113c839d47a4b81425c5ac14b5ec284ef18646d5b9c295a98cc51ebd3b310e98028e24de092ffc76b79f440740a1ca2d4737b9f38966257c99a75afc7454abe4a6dd815be8ccbfec2cac2df0c67541f7636aa4080f30e87b712520fdd5dfdc6d3266acee28f5479f836f0bf8ee2112173f43ae802fa8d52d4e0dffd36c1eac3cbda974bb7585fb60a4700470e3d9f6b6083ef13d4a5840f02d01306c20ef5e35e2bfdad2f85c745b5b61c5ddc65d3fc97f6ec395d4ae222b8906fb3996e2e4110f59eb92ac1cb212b44128bb545afda80a4fd1b1ffea547eab6bfac3d9166afce83fe35fe17586f29d082667026a4c17ffaf1cb5014524f27b316acfffb6bb758ec4ad60995e8726359ef7c44952cb4240355ec53461dbd24840a1586f04aee749ea3fa4474e52c13e8f52c5156230a1a70162cfb8ccbada27b91c3333661064d057593388bb6315b0360380a6b43851fb0228dadb44ad3db732565bc37841993c0d383cfaae0bea49476758acaccc69dbfcde8bf416ab0474f0222b7dbcc300250220dc4e67289e500068424fde951564806d59eb0c189cf08fb2abc3628d0ee78a6cace9b6781bd504d105af65fab8ee625264a8f8dd8e2d14cb9d3354e06b5b53082840d3c0118e080bedab3c4ce30d722a45584324955a20397c1782495c1c5114e8656e71c31d813d1f0a6d291823a16327f9534353fab89529c2f034fb70e9b12205c7b3a06c87969407a2520bfa2fe80f90da1efc3d345c65313936ec023811a8cc87128be2fa4cd0e8645ee141be7975519e2b639543d23113c2a83d87b0da033f22df0464c704e9d47e1a30947e867e014ae464b379355c4babf689fa4ec4aec0cb01cc35328c0e4a0230e4fdacb93b41959426deefc8a553e66e75a2d790cb552c4554518f739694b77184cb145d95f883f620a8bbedff42866a27837b4ee6304b711ded56e077a4b9fbc4e60e687ff6c30cbf144b8f64d5023dd10a35edddbeaa3323e999c6d2e016b31c38c48d2917a888f79918c3abd28e736b8d38e69b4966cc624db0143dd2e75e2fa510f632b7ee6e64d45b139aa1c6d852e74be7429843b9e6bb7edb9ab07c8dc2679efa092299f071dcca9e0e61e96094406fac95f1d8d19122f3f887821b11a662e9c83fd161fd6fb7f03289f7d984da9d48a3583fea45fe58885e2c4839e25447e87235f713b1f4732e05b71aeeae026d063f43490a481d2db197afabfce1039d4ac04a6b89d2d1aeac0842eb7178cc53b82ce2835f19373b4002ca21d6b6e64a78a78abb278bd6142ad04526e035dacb23624a4cf801101357717a52fafc92745eefa28a290ea782735617cd8b0221b095e9f4b286a5021e9ba07276453e58e9ec16ed1cd7732bb5ba99a6374bde43fa89a9cb83e5ef2e4d041da4f73566d134e01da194625c25d62018764d747364643721313d245a01badd970941481c9578781414a4d3faa92d1fefbd4b247d37862a5332a7ca3c2ca6393ee51989d5a901a6e564040d37390c472ee27892f0217fe009e9b45d3f04da415b35612ecd5b8e4eac757e27d2169f2d92853b737b75269ac837c86476dfe956c2b45ebd5ed4fa6da687ac3960f4343669ddd364b8d778e72e78f86cd55efe92b8a9adbf2e728440966c8282cee1f9ea195972b883f446ac03b37e7f24744df253954ae522e3f9a0adbc586add7c7d8a2961ba963e4912d17c2840ac28fcfad98d8ec3ad6dfc32a3c788dd094910e65ebb61dabb5fb50e906b28c881003b11eb83e6a9a2fac0595b138d3d55a28f915330c343bd1849a08554c786629d2b421d465cb22ccbc2d8f87fd52aded1ecb34f46656b71b4cbe50f839f2c2df6a553cc369840b2dd25f26d51492f3c5c6fa566f80dd453864548d4be786d8735d9e364511a0fb62d3c2df64d6d1c9ff640e4ef4186be41773025d6ff576147e75d7df3f549809548639d1601067ef60342474e7c1b20deb1543f8172a6b98ea0b0691d4b575801136a88607a3e5b0180058ca8742e972bc2ca1c4cb67b05bbc57e63df5f01049697eaa2c537f3121384dcedb1fa0b34f132689b1374cafe25802d7bca5c6674f8e01e75e9eb3da59c2d9126d85df10f603f8c4fd9d5a358aa84b2d5f8320f2a3bd078019bcf0dabb5c343dd8dd5e173f045169f788a0233d62daee0e9839c7d673cf77a53d2008730faf272d03c08080778ae8d920e40fad87d7ebf118230ffb194692baf40b951b483549affe4e38268e172f86a40b3aa5e2c1b74636dc3d7809ac68aae33c344fd9bcc336e6057dc7d71f0bceef547db57faec91cc1056e4b58153f00c8ef4f8a2ca943ab03915079a070121782dd592dcec23dd3f44ba5fe5078279e6f8ed790ffa59e7877e834b4391d1ca3db32bccd7b382e35bff1ba196cb3b9ef8671e70342fff9216a5d635530148dcc6bf40909f72ba4be3697761ac11f1f2a77a5f435c5ca57729bb9aaf3714f78a30f9bf6f1a7fe7f0271b010b224bc83ef07b0d409ce2157473adefa793287d48a6b13ce8e00a7f74d735fd54a00be2dc16285d1b5a8b3d55371ce703bb3909153586b603c8c622aa53e989ee3322e069aa325ce41fbd01752cd1326421cd833c47eed2daadda87c2177de0c63f39b496d688c971179359349f5e0e3cfa9ea9345dbc47b1948cbfe45f2a13b18cf3a0d100b03fc13e6cde656ef26757f5d17c584630c27fb202f2e14ca8a67efcfec5279781544ec09910379625e90fc0a898a5b75beb0f3ee5d03a2383832708cfb76905747e27453e1714e418f0f0a353bcdef0965e8d2c9b5813b90c3cbb9a20c8ebb80e045e04f3d579186fe6ffb0718731201760abf11c27e289872adda7e1233e7ef2b2c83b423b4c0ba711db334b15e5bd4c01034d1e41bff0e858a436cce28ea3e6ef4d94b49962ec8728db63716b8c8ffc95c21b060beb50502d9acbc1eb732268091ae45e0c30cfed3631d58c384bc3e48a26ae8b7a5c6083991e11e8a21ee4f193c0183e07691fbbf9ccb4c24e5214fae905d82052c969e9699df6cea5a6157de3fd84477a6bad8e04f37758724bc3a491d0fd8f084e19933cec5f51f093794e76e1f29bebd1f1c057b30c7ec220fa6d31d9867d711c9a7674a700cf5f177e37cf3fae5da3ddc44e8030990c7917553a5ce2abaaa4c2296c42e2dcea19ae4f9b65458166d5fff1163703bb5085e0e7d59512605df8a35f9f35c6d572c28ea55099437e5f5595fb45cdaa8872f16e012db5feedc31ba0e5515be76fb793b687fbf1dd9d2c01063d4ca1c2e6fde5bc3a1cc17b11e1a33418436fcacef170c5e4c3cbc30666182063665d2a1b84a8b5b4f2e58850ce74bcbc892d71b312d96806cdc882d9c95678fff15d8a0120206c3c621f13db39bd6e4a5db4815f181d8dae6e596cebd51b8b1681dd49181dbcbd79f8e5ff135064b0968c4ed81e91507c1e96ce08e072644e54e1648d32befadcd0b7f41fca118d7b9291b680b18a10ab9a2fb4f9a09f462d2370dd03bb453f4b48b2eab3c3e6d63c2559be4aa3d8e8f12990af78e01d25c92e06a8715063da988dbf792de66917eabe5b043c41b1f700946e4ad2e329ae8a66581e4a5bda0ff2a31379577080aaac8c0dd34f4f929df30f5e87f82b9b1f1ead67333c42d5ebac8fb8797375dc26965e625abb953ce074d8c84c2edd54991b2104a45196065c2bca98f56533f328bf8560a1a390e92137d2506aff3d7bf88576a47d273e562b7c9592ffdc2d0ff0ba59787b4dd89971bd39a67a4a778d69a4cc58bad18bf5fc745cac8d53dcc72cba7e9c7a2b57d7ff544acc98f08f1d22f503712081cf868290f04defba48ab7c61a8ab3ca439f055f7132401e3a43338e0b7c4b19cf1edc837db6b0d8991a710ede95c9c35e6a8f021fc8701266e5909a7f3217b33772e647266ffa5c8fd0c786e0f04f0bb34025c67cc33c6a49bf10145c563f33f807d6e95e9c2b5e3493a0e55d42d44b7611138d0e928dd24d7958e8e6149c66faf12b50f45eaa5eb19337961e68c81cb35d5d3ed1fe1f1b8d443612ca593de8afe6c15ee22ffb8b0c27152ca5a1e770133b8165e3ed1608c9c1a6ca4aadf5272bd1b64256f7efc5b2bbfa0b49b5f0c67ee30f4ef0e7ed820cb4b14d077b672ce3a60f2386c02189e8d6e5f6caddfa53ccecbae8684d3183beeba0cef4cd21e6afc08e85db41995d15a936afe570246af77d0994bc305b27f2de99a0885c9091629a47aaa161f0f6b6d45ff8967cfc4e83f5b469ccc22586cab393629e6b3f94d122e83f00e419d8980bb282b6f3efdef30d80463fb25e01846f8f1b935d33c03ed5243b7b4cb6b0e6e4c770f8bc2856390163a73a332bc2ebabdb3aeafedbc8c0874ff7726398cd40071d5d3644b9745dd1ae0369e9ac1f518cd384512b933bc25cb34029377c50007d647e609eb009c92457d99fff828ba6e9f0adcca6cd0a95c5cf8366b699ff00f513ad9e29d7c2ecfdb5afe401f131691f0677b30e1df0cce8710f3c52df030e941b2bb6b650cf2d7012a5a2d11f1b44699b78e898918977b2e06972b36674e2619e6be9793007948f99eeeaf2b5b80b81bb3417446ac93bc1614fb20c6ab0e243ffc77d167277136580afea2edec48942ed95911c5fa312a7aca8f83992e36a47ef1db3937ff39b1a9b52af79ef5c48c646c88d58111a0b7b6fa6dc5f7c8dcb1acc64f2b083d332baac65b4febe58dae530ad4af0fbdb072d0ba36e2607b065b6fe4f803ae22cb2a6c9b639dd91166ccf5e430b9cece8c687c1dc2ac5898b429122b168f1c4248f91ae516051c24d7f1578ba61dec5a6c003598e3c04b01a812a72df7909352cecede31efaffdd0d4e4a7f11873ec874768f7b8d7758323b6f7bae4521f8fbf571e568d5a577ad8b71f3721718b68ac1ada36e10689cc83ea9143f73798b295f76e2b078c8d68e5613c3bb265ca36d25d07032b8c80843fe3783b5959e918f7789f0d33afac1cb15346840fb3c6c442a94b167f58645b56c276132472470129590ae9be533d3975adfeba5e623030dea290d933d708cc4d30a4af3909bc69be193a2ff7f8ff9f03af3b3ad1a453e9dde4a534709b6e15c7c6ce7d4efd42e95e947977595b68ca674d0c7541e997f178a43b6057137a6483c7653a49f1eec3082cc770824eb5bebf04cf95519563f7c7cef140efdaa4314f8ddc5fb7000927710736a485cd41b05dfead9e7adcbf8e83a3a89a23e46b5a421a0884f0fb922099a4120b226eedd549cf4706582b36f4e3b718cabb9c1103db1daab9520a3a29a8c65c45f60219e82dbeb36bb351c498a8dda80ba2a5607f3bf60b95be14721f6362d3b4d2b1fc16f46a95de23a55eb70c2f136e83eba0b215f5837e73d76368870bd5bc0372cf15e7ff03c992d9585980141fb03e9712f2c4a73b9107699fb2239ad1d706b5f33623dab66fefc18b5e04ac40e7ed77eaadd7c4d35cb3ba11dde839a2621e7ab334235d29f2ed9f1990d9e0d731952272a4d31f58d8cfad6457690ff74579fee78fb0fe43c6cfb127e3c5c7da881765c8883fcd01dc0028f618172d07d8f79c0e5b79bdff41e18ee3b30990bd1c710888b0ef52eb6da5bdb790ff7419e17d22ab4221d42b9a35bec4ded01a536a2f35fd63b686db66f3c21b9291165a5fd321d034f2ea034bd3a6b64d47388e2680b7018dd250cfd53b53babaed27080a73c54d98e4a3656a77f2e71cfab64f9539f7e67a64c35beaa6ab55281698a8ee44d10d01e623ff7096e896a68072d59c566baba4b0d232ee725a1f9e0fbeb197728ef73b9a8e16ecfe23a3bdb6f035aac743b427202c094281f68b1c8be9e39e45910959fad0920ae615a97f475dc632a3fc9e9363688a89cea147f0339bd1ffe6e68570d2329a0b16c32fa2cbd5818383dd8fc26f57abe7c8cd4d680e55e8a77dfeefbd47b284a341bc9077e7df691c32ea11a0df3c2ea8501eab0c6963dff30ea51c9f8de69a045d957b4036f90d8e90b75886f2e5059e5d7341e707011eca8d6006677dabf12c6f20407419415058a43d3958d229eee2b01178b8eb9e382e6ea2e562e44ce8f6b19ea5b4444f78d77dc12755f1de34c78fd001eb8d0d918a3ece83c541b5659f736aca90761c1864cc5b30f11b9f901459a142f5571fc19f94a339e842e17176caed2a1659a97f8e625e74d131b3dabdbdfeaa0366bd95ebf86c33a6874a09faea206cd129f59174377238908e6c956350cb686a225a26548ca45140d1ed5b7675e9ea2087732c14dd568be007bf3668e3791bdd4b56f9aa39df5785e7b37c964271c9c5211e837c726e374513cd4cd34fa5c71ff1a4195e4e234c5adc13b475093fc66c8faf2ec02dd6ea2715d8676bb21e7f0bb4c22ceadbd9079ccaf78857ea36a28da605bbf2d8723651fb07c86a07039b49d2fa3240dbb6dc2ef93dda48f7e9d5eb9245bc6190b3a9e4fc84b55352b99425f44b36a3fb83d09a8f4ab7d78e0829201a523b21966e00983956565984c4e317d930581dd2ab677c99a92a70424c5aae4ea1dbaca67de1e45918a0d6d5601e5c75efdd907f99a6e56cbb015f04fd11c8ae4d0583a72f3e967bb62ddf23b892d1e5d648bbe9e5f8d3d4b128d667ff6a781dcd435b03f41a1cb99fc298e169d80c51941a265263476c788bb7db0b584b59ec8dd95a4e9a6a95c55263b0eb0cc8d498e62e5116ab0997564c79d4b73339d708c3284fb2d2cd596efe674aa9e3b1f33b447370b30aa67c0c2c3532c9874c8ce5680a796f9db4b364e5825663090feb0a67604f3f9b7c4716c88afa20cecf4b6b1467f8342600406fe556200290eea5690336562b6cff764cb02d3847d68f8fa26c2ab20fe0635de36be096db8dac5998b94e3c174c8808ebb9bf534bbf0a436470dad3875253f7b0a9a99369bfede3488c3391fd3a5f955005f88c89d735acd8196d21d41b5ba2ce34f48817da3e7f4332994f8cfe88c8ae18afe4df8b64d16e61b0f200ab8229f95a15b4ad681a60350a1bb85a5708f5731809fe17da9da29858778783e496533ffbda6ca590c76b953dffedbf61ba227191f7fd713fd0b4bf4a5e6df990584542ed273f1fee88e56d34cbb2866dcc76209f9773ec4c21238f991ec67adff263cb22b14fb41d94f97f42f26d90e0b24a1a37fe90421cee925cd69e29e95550bec2bff0431bc06acc812fa97ad44f19e44dd33a0ed9280b1ae70cff6575a036db7f1e7bf2ed31bcef8e45dfb49b8dc51de1fd10fb1b59b8092da05f342c0a01fa56a0375319c1f5ad03dc627acb1f2c96f114445d67a093467a43a832f56266f0bf7a464d7fab7c4842561af703a045c1c9b270211af3edcaf802cfd3366f9ba5cc39c3dc585554fa4224ca4a7216b8d2dd3e16c2d8b31e6fa9e9ae301e1bfa98ac8389842b368a158c5060209885c01a2c3f5b7bcad20124920faa1ca2217820d1fa40803272c88d1844c2554237c9ecc8d25f509a6db1de325148c1726f18398c66b13390488c8c43dd7f2c2624cf4ec93ee49854618829620375eb494db615a50f69e1fb949b42153e02e353426513bf6ea2adefddedfbbb781d40e52cd6ebec825d94a03f84de44b6fd500b466ea04582903a77f7804e0c62b0ce750e2b207869f346f188a43a24ef26f7c284a3544ea716d5498b3e1f23b1154dcf6d5c580dbec7f0120302c7a16ee0bae4ae638ee50260cd112182bd84dbc443744789a87faefcebed3a2c579c0f77cfa5360d920b050cb068fb2fc616ee5eb83b7082e645d41940df3b620a8474df360190d74ec728f0d33396ee1e3c007bfb335325ac5c5327fcfbe99daecd75584e11770aecaa7200f5ef955be60818788c906f9fbbd9a8f16d11b5a2980cf837a8f49c037833efbbae308e710bda652822a3098990e49a4320ce8bf60c5517e8530b0f2a3d47d09bb07d28e7903ac95009b61262ab9c0161bb90668bf4a314e46c502058447250d9698fedc3e4ceaa255d415ba4045c2fdba817b0720f52e7360eb0036d8439d09e15116b8245e23dad88738ceab0260986d154e9a956cd13e67e508e9895906f7a2bc24970647a63ed025e192810f2e04002e7f4cad9b4cb18d5850dc181a205204ea9653f182d3b188124823df9b34ca3d2c93b2e5ba515010f687308114d65f874acbf4d6286131d46681d439816a815fc07b05c47fef0ef6a332c3132c4630529dd2021a743a1e9423e63b12af7fe3d806e0cb7d03c2afdae7abe068af28323fe75b567a2c0c7069313cf6c1f44a39aeec0ddcc87747c3bd20c1471876af6b8558b0feb0b357c5d8f97c64ac9dcac22f2856e4341b42b50663b16ec5eb01f0d31dd990e70ccf7203530ab3d196d42eb5412ec69dc9e4fcaf97880e0dcd2d94a10fcb5f39a9e8312174b084adf9c02c4d3cabf53a978464c3319801468463c9f7c840833beb0cb542c3108b19dcf7401e6f79ac1f27ed5dd4e0e509cf69e83c56c15ca00d43e17585948602f5bf14d1d129ae6b9f4ee2b58f973ae29566a6c792feb0c1362474058c00758caab48f22b2e6aed88328618842d0418ebd349eb34846eda10087342e8b6c21b95cbf9cc90523ed0cb594c9374718e79ca60c8fa29dd489a41f2190a03e88f8ac12bebb17c5e3195835960d6622317a3d2d90ead5f5aeb6d34f4e17a39957a01179f3f88d79fc83f9cedb1049a771b1e30a85067c640ed06cac8047923de59bdda0f1b1b9d7a014eaecf61b7292e8b0f8656384dc1de3d7f5ddad9b1b7557b4db854813ab90c75a39b35f03246f1e420f760465bc3470da41ba5991181a6a49de8fdf50560b1ea116f81a6ce2716aa9919a7e3fce68f208dd305d5b9594f643dded74364c812db16b6e7e4269696ad975ff975a7274d6e503b6ae9a99ce664850ed1daa714650763250b944b7b251c3e6b0d37d4e4854c4c06c7e1c3d4b9175602bc6955890892f5ddd9a20bbd84d12a16b5963dd1426dd7f44f0906cca7d8cd71ba710072c1b4ea7aebabe1e8242f7269960c6c0d5bf32084edb90ada1d235ed7d8a9fe393b133ed8a3fec1132c4509579af1203ca5447787a5ca938128fcd756ca569d31b6f05dedec4129270543ff17078079c2aaf642caa8568a3b8d1f6c3bf9b5e7c947c61701ce121a3808b18cb73cd1d7543be238929917eefd8b4b7d0eabef30f24b08b72c10d49c60a3c01344f22cc2a2b97c57f2a37b00f82a2f9338e5205a8b9c9ce0dc1d8a4d7e7260e25762046c5551c0e919811c1011cf28dc158db4a957c2b516e794206aa44a9e535622d8dfbea44b252b2ab87284568528acd5239ab1d64c7025bad538907922d657fb163fcb9ecaad97c1507e480a78e8cfc81ca93514eee2413bbe9de349073d92ab5c8ed191d530d9aff3a72b6e194e41d26925b22eb6c5f709c6088bb4198527923aa6f4f31345fcb8916f889f82d7a298174bb0a41e5d16d9d428c7eab4098fe2f34abb591392d4a508451558611871f3fcfcee19ff180d1b40c23b7cc18c22be085cc3edeb86d04f3c78c56c61899b80112cf78b1bcd5b7799247be60f0cdb4c8a9aa7a58409e2bf0ad4cfe9b6f79b501f91d3645fd2c40e48e881c650973fb8e6817c8ae6d3aca02c7a01c329e3bf173b126f2cda1e76229d405bbc41d35e028a9f38856697e13e1dfee5e2aa02da00a5271abe2abd92296fc2e380153ffa1a5ddc3c184ca2fd9a8dd7381eccc7e055a7fef225257276da25ac98ef003e12a21d43ef9228c5f1d9e71a96b7cd9a47a9c9d8aaf77a035397429f8854a9983a9c2bcde940d643506986616ba3f75fe80cc522c68b65f03f78b91d9f6cfdf9170e4ac9f1c84c3819797def03bbfca03408802893d145bda408df07456e5388bfcbadcc8ac22dc9365807ab820d7029da8be4c0de87756ee3a7865bfe46439df366b70bab960b51e728dbe2e3c346921e4e74c6317baa49fbb3efd421fb40bd979d2df24bca9398d5bd5de71195bc030746a50c5902cf2a4b1b9812467af79145cfaa0ed643c7b530e4181ef7d406026af6ea606e325377a302d06af1f7ccc7658f6ae6defabbe5314d959e1fbb5757386c87998759670183f61858e0cc3816f883c113183a0578eece5456e86ee96bc04285b8c56bb174e5fb66d586e69d8eea215e70c8f4a00feb7bc2f6369c2bf470063d5b267be08f0594c26fb2440b1ac68610ef5a140769bb3d5b50a536d4df6c30bc09f97174e572ca84d1712deb91e812d860b17ac9ae5be211c95a0e3f542c7846397245b13a991806ab9ceb66461b4161b0ec2edcfc536e2a24abf89f7207bf519f1babf95b0d0d3caed9e17ba1bf76786526f524fad677ec243ad271d0cb9b1c06cf7376050a36697c74beaafa0f0056a6bd7e9f2d03db497a93027d76e6e8692a72ceb29c5913a755eb297dae3330eb676e7345fb397021192efd5b47462906905e7511e005f52fd8da5e1288c01960d7353460b18eafd2d8faa9b1c3caf4265035e585d9fd2d85636dff1d4e42600c4b7f66426702b21e6a8c7a0379ce25c264e2f4035a7f32c227eabf8f711445a7d7d0b5e3b336f71ec454a416321483bdc1a7a9d20deae1ee4744e831435b6969f286452917a6b42d6346abff0fb6edf2265aba75b0991f6dfb6638c1d7243ff8e7806af6600486dfe3bc58f31717b0c4adc2717922c11abff0b4a29043598e076f60be2ef17ad2f776053a41a09d974da6ee787846e7ff26ce05d869fecf18fde916d95f93574c1b4dd723b90db1f024400d61a2f51dfebc71b770461e7f725d96372b1587ff40035ea2cafbcd0c6b172e9efaf698604580e339a823ea56febfaa02609bb2a33955624e1602a137b84639ef0c6e2ecf420a6d6b69f13acbea8f97b4d36c41e3a8671352aee4798c08e3ec254ddf35cbab600d90f13919d00cc1d401fd2c1c629e621756d2090f8d6e0895fa701bd1b0a355cea53c7c91b15eb4dd8579d4dd92e403d1c960c63d55215a8fbc09cc8559c1e6069b6dd1a0428bfb223cca46d131153e9982c5dab0c9ffb93d682db866d6503ca481c48384a087a417c5645672582ec7b9722b5c5f2d491f9cf7908630cd268b1088d0f02e69b1441963d9841b5339d18fa26deb7b957527337f3bd67d3c51e6839a4d5fe4cf1619c18889be68d971f0f57d101656213ebf152a2d9c0e0394832c929e6fc90ca28ba59c5151dfbb8394f49fe4cf2a3f7a97f4db054b2b342a4c21abf6406feb941a80bee3f87615468e80e77a0f935ebe8e8842959f2b3ba1f50cd6bc8b614e39de3c43d13746983a7956e61713124756de3547cf1010c16d5d1fce2bcc3e73e5ef9fd6911211c1a27803adf1c9644aac4ba28d67134e3be189d8aee617c607cbf62677b30d8ecee7df69402b22916ec102f220e09fa6223e874c3e53fb474983ebdb9f806832bde2f4e67c25ef688134b34aadca3409a6b3bdccd638f3b19a2b01f18625fdd10f5e91c28af081f28e4dcd9077cd9229d87caebbfb072b846b4d2ce0fd7a25e195d67aec9546899268d2ff3068a2e9d0c2af9f2fc2de997801b47566d0faeffc5a8eab9667204b981c9fe7ff10b4a0aa0873484e25a8b544ed8801c72530c2e5d37f94b0483e74e4fabc5ac97d82cd681a23d34cce0d526e4d17a8475b1963493b14551149d36db24ae5ced3a24a53ea6aada0230cbe502aa32e2aa07485f281e666777be0d719c75d3ab65be7891606076f42e71bd2273e56dd3eccfd5ef1c9394b6a9e42f1f49590ffa21e6ab6994e56a88d54a339e301c2efff698c46e74e6721df7c5334d0f36cf6a93bf3ff91d8979d8fe631321dc8b5eccceba237eb1423c3954623a16cc50b7983f616f60d811432c15a65536b82e4a00d384d99cd369206bbef6fb442a720e294a9e4768a1c77e94dac31d4798dffbd75da46bbd77e908b0fc027a69fcccc4204ee745159f5c14155873d42b27ce0c031527eae22fb1c9d6da9a733c940531510c9d938e52464ce71385b73fa95a2d3597bf6362dd268f99019216544097c8d064cd5b4ea80e8fe2f1b3288ee188609ef2cdfbeee34a1c48fe2459cefca35857f33b5320fbbca797789297027b6a4f1debe5a09d013fd5d818a56bf6319a092fb1ec45c526f5d3ff643319b8295291aef56d6963c3a92c34c065482a033fbbb9b9ab43410d76444ebbd99c86a864c087234311b85db6e5a803ba13f760c159ce2a619d58d83243fe0ba1c1e5e83aa79b575c8bbae9baabf2ed91bdb632ae88e46b443cfffe5afa4f53f1485770be538701c4afa3fd89c44ef7ced060dcdc21e93680a5b9e2ba4a53b63db0419a96d30f68e038377a61eaa15b78389ec745f532809ff80f1f2892acc49ca4ee2d68174c08e81378254a38f51380b060222bb20b18013f6f4745c47ef08e87e2c197db69d5ddaadf4177bc66fe482b730f4bd76d3bb1dfc09492b63f2935b43875dd685ab00e15a528f666486aad1fac042ef90b3bb7b8ef9c2e9c78967b9392a1c2f05fd5ca0230b1008345afdd18cdac73c313ace60346d535e500b6212e6357496459becccdac5a349263b880f7098608fe66c3352a9cdd6049b176ff1a04d897d9569948066806230e9740d6e179ebf2b7952ab3a2c5079b5bbea73261b85c35fb15b917dc1bf7e579c55b95581c1d5e1fb86e6219639c72a22d840444895dc5d7b966027457f3fec730d5d469cd82a2b3cec021d9de560b8d685b4d126933886c8265dafb873258741d99af7f4201329e52d3e66f87d37c458a6ad051241c5ccbc355b7fdcad3c3c269d05f04a0a23acc7ce076aba97cc1874b36afc4645b2cd7adaad8f5b91bd0651649dc7223d9b6437c667fb6827ec09eed45e8ad6102faa934f1a80658c0bfe1eef1749235ab59f75478ad5949a0649ce6e198418518df41dc39cc628bd9dc9bec89c8b7771a21fe8028c65082929b051f3c657798a3aebd1ce9c37c494cfc8156efce8330e42d0d95860d39040dfb0fb66f814c44b421540a0aece9e767cbf7e9c49eeea5b5c866a9ee2026ca4bfb067ec9fff1a5d41c0290ed4da32d33365208d00dba47199e1d15a83b7365585401976a2651668daeb4aad72cdabffa646baca7a6c7bb29875f71a87a53a2139c11ecf7ae823158ab1087bf595f7f2d8e668fe076e4eb0794cf137a86381e2a419a320ac8090b1d39e5171813903d5f1a68cba31f8211e56bb52413eefa30a66af88d053eb8a4a4d2235fdb9bf9169a947973d3ed30dbcf583c26ffdb6bfbee58458b75a12f3e625e5d853ae22c2b1bc6a8e6f7e7bbde6912b692a6746d3be686438e4ac66e4aa77be2117847136aed3fc3ff0798c9373ebb1c2f7bb99fd5bfaebc1665902d08610e88af0db91b80b6e00d4995f9a6ce81d503d26442bd9e61b181dfd09492a02f5075a277e76caa7ddc435fe5cedae4cae7a574b5f7c58c4f2141446a05c1023ab459c93a9f5ad371ea5f5aa4060b2a48215350fcd60ac21e2a4729a51f18cf87ecf430f0fd48c241ac6bc33964cd2e3d9ec8bebeffc2e848ebb84a5c2ea9b0e311f20ff7ce601752573f4effe9879dbe4d184dce56bb04def99d3227d2d5f23c2475b7f93f7dbddf04efff303e751fffe08d205f8999a3d5750d14f75e0561107a3f96ca8e9f62b50c8ad9f2053e7fcc55d72d86345dec1054cb601d52c21dc654aaa0bd78e39c5942265b675381cd557cc03dd65f8211fa373049059a89885886b48085f8357ab98192a145bb6cfbf84048b5cf862f25ff6abc9382e36ab2dbd2357b5ade91fcf2db77558ceef24d4a0cb3ba50a2a12c3cb633dfe47db805410168807a5e635ac766e1a25252810f49fadcae296fce18ed4b9932d5822c5194b7006cc54ea842546d761d284cf2346d0a11b1ed981ce0d028c4474c8002fd03153728670db1a6ad6eb4c7f942260e9c9822bb2c423cc53e3b67febea367259c24223d913c36f4b196f69400f51bfb6cc7f3603fb9fbef84ffaf47c1632636806f6a50ec42076931ff68b2be9e5e7ad7603302a518bd4d7cd9bb97ffa3cacf1faaebf7412f55d55d548bd865b34112ed53d061b58692e1e33b7cc7e3cb6d32fe28f7b35c14a744f9a4ed5993995548eb369e71641afd4a6d1a5c741238cc7ec376acf04ec0a470647b2482fd9e8eea1f10e944392856779604d11f6e6a426e006378817230b68ec14f2df152cb7199a8c0bd5f05decad5aab44ac2bca87ab2ba6e90569c0bf2acdb36cd66279737bc8074dd946eb19d81b4e9c473b5e98465a016f7ca86f9dd02c2b7dca744a";
            String personalSalt = textBox2.Text;
            if (comboBox1.Text.Equals("Standard Salt"))
            {
                return saltAES;
            }
            else if (comboBox1.Text.Equals("HDCP Salt"))
            {
                return hdcpAESalt;
            }

            else if (comboBox1.Text.Equals("Personal Salt"))
            {
                return personalSalt;
            }

            else
            {
                return "";
            }
        }

        private void textBox2_Entered(object sender, EventArgs e)
        {
            if (firstEnter2 == true)
            {
                if (textBox2.Text.Equals("Personal Salt..."))
                {
                    textBox2.Text = "";
                    textBox2.UseSystemPasswordChar = false;
                    textBox2.ForeColor = Color.Black;
                    firstEnter2 = false;
                }
            }
            else
            {
                textBox2.SelectAll();
            }
        }
        private void textBox2_Left(object sender, EventArgs e)
        {
            if (textBox2.Text == "")
            {
                textBox2.Text = "Personal Salt...";
                textBox2.UseSystemPasswordChar = false;
                textBox2.ForeColor = Color.LightGray;
                firstEnter2 = true;
            }
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                /* Decrypt(true);
                 if (label1.Visible == false && label2.Visible == false && label3.Visible == false)
                 {*/
                e.Handled = true;
                //}
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)// Copy Salt
        {
            Clipboard.SetText(textBox2.Text);
        }

        private void pasteSaltToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox2.Text = Clipboard.GetText();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e) //Clear Salt
        {
            textBox2.Text = "";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text.Equals("Personal Salt"))
            {
                textBox2.Enabled = true;
                textBox2.Visible = true;
                textBox2.TabIndex = 1;
                textBox1.TabIndex = 2;
            }

            else
            {
                textBox2.Enabled = false;
                textBox2.Visible = false;
                textBox2.TabIndex = 2;
                textBox1.TabIndex = 1;
            }
        }
        
    }
}